﻿


<div ms-controller="tmpmodelview">
    <div class="control-group">
        <label class="control-label"><b style="color: #f00;">*</b>分类：</label>
        <div class="controls">
            <select class="input-medium input-xfat" ms-duplex="modelData.Type1">
               
                <option ms-repeat-el="CatData1" ms-attr-value="el.ID" ms-attr-selected="modelData.Type1==el.ID?'selected':''">{{el.TypeName}}</option>
            </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label v-top">
            <b style="color: #f00;">*</b>
            标题：
        </label>
        <div class="controls">
            <input type="text" class="input-xlarge input-xfat" ms-duplex="modelData.Title" data-rules="required" >
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">视频上传：</label>
        <div class="controls">
            <input class="input-medium input-xfat" type='text' ms-duplex="modelData.LinkUrl" />
            <a href="javascript:void(0);" class="sui-btn btn-info" ms-click="VideoUpload()">上传视频</a>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label v-top">
            视频图片(750*340)：
        </label>
        <div class="controls" style="width:900px">
            <ul class="sui-row-fluid" id="layer-photos-demo">
                <li class="span2" ms-repeat-el="FileData">
                    <div class="img-round">
                        <img ms-attr-layer-src="{{ComFunJS.FilePath(el.ID)}}" ms-attr-data-id="el.ID" ms-attr-src="ComFunJS.FilePath(el.ID,'/100/100')" alt="">
                    </div>
                    <label>
                        <label> <a href="javascript:void(0);" class="sui-btn btn-bordered btn-small btn-danger" ms-click="DelFile(el)">删除</a> </label>
                    </label>
                </li>
                <li class="span2">
                    <button ms-click="FileUpload()" style="margin:15px 0" class="sui-btn btn-xlarge btn-success">添加图片</button>
                </li>
            </ul>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">时长：</label>
        <div class="controls">
            <input class="input-medium input-xfat" type='text' ms-duplex="modelData.longTime" />
            <span style="color:red;">（00:00/分:秒）</span>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label v-top">
            详情：
        </label>
        <div class="controls">
            <textarea id="txtDetails" class="input-xxlarge bw_ueditor" rows="5" ms-duplex="modelData.Details"></textarea>
        </div>
    </div>


</div>



<script type="text/javascript">
    var tempmodel = avalon.define({
        $id: "tmpmodelview",
        modelData: { "VideoType": "1", "Type1": "", "Title": "", "ImgUrl": "", "Details": "", "LinkUrl": "", "longTime": "00:00" },
        ClientData: [],
        CatData1: [],
        Init: function (ID) {
            $.getJSON("/adapi/base/catelist/0", function (r) {
                tempmodel.CatData1 = r.result;
            })

            if (ID) {
                $.getJSON("/adapi/video/model/" + ID, function (r) {
                    if (r.error == "") {
                        tempmodel.modelData = r.result;
                        pmodel.FileData = ComFunJS.strToIds(r.result.ImgUrl);
                       setTimeout("ComFunJS.initForm();", 500);
                    }

                })
            } else {
                ComFunJS.initForm();
            }

        },
        tmpSaveData: function (lyindex) {
            tempmodel.modelData.ImgUrl = pmodel.GetFileIds();
            $.post("/adapi/video/add", tempmodel.modelData.$model, function (r) {
                if (r.error == "") {
                    top.ComFunJS.winShowMsg("操作成功");
                    top.ComFunJS.close(lyindex);
                } else {
                    top.ComFunJS.winShowAlert(r.error);
                }

            })
        },
        VideoUpload: function () {
            ComFunJS.fileUpload(function (result) {
                result.forEach(function (item, index) {
                    tempmodel.modelData.LinkUrl = item.ID;
                   
                })
            })
        }

    });


</script>




